Back to Editorials CodeCraft β
  • Github
  • Instagram
< >

Even Vowels

TIME LIMIT = 1 SEC.

  • The English faculty corrects hundreds of answer sheets every year. One of the many questions that are asked is for the students to write an essay. Weirdly, marks assigned for an essay depends on the number of vowels present in each word. This year, the English faculty has asked for your help to make their job easier. Given the length of the essay (in number of characters) and the essay itself, print the number of vowels present in each word.
Input Output
First line will contain N, number of characters in the essay.
The next line will contain the essay itself.
Print the number of vowels present in each word on a new line.
Constraints
  • 1 ≤ N≤ 104
Example Test Case
Input             Output
11
Hello World
2
1
Solution

#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n,i,vc=0; // vc is the vowel count. string ip; cin>>n; //take in N vector<int> op; //to store all the vowel counts in the string. cin.ignore(32767,'\n'); //ignore everything until a newline(inclusively). getline(cin,ip); //take in the string for(i=0;i<=n;i++) //for each character in the n characters of the string { if(ip[i]==' '||i==n) //if it is space, it means we completed reading a word.so store the count { op.push_back(vc); vc = 0; //reset vowel count } else { switch(ip[i]) //if it is a vowel, increment vowel count { case 'a':case 'A':case 'e':case 'E':case 'i':case 'I':case 'o':case 'O':case 'u':case 'U': vc++; break; } } } for(i=0;i<op.size();i++) //print all vowel counts cout<<op[i]<<'\n'; return 0; }
  • #1 Thieves
  • #2 The Queue of Doubts
  • #3 Summation of Primes
  • #4 Spacious Maximus
  • #5 Samosas
  • #6 Reasonably Sound
  • #7 Product of Digits
  • #8 Prime Usernames
  • #9 Path Shifter
  • #10 Keypad Count
  • #11 Even Vowels
  • #12 Encryption
  • #13 Decryption
  • #14 Canteen Accountant
  • #15 Attendance Register
  • #16 Amazing Year

Get in touch

  • executives@codingstudio.club
  • +91 9010342360
  • Vignana Bharthi Instute of Technology
    Aushapur, Ghatkesar, Hyderabad, Telengana - India

© coding.Studio();